import { Entity, PrimaryGeneratedColumn, Column, Index } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";

@Entity("market_stall_items")
@ManualTimestamp()
export class StallItemEntity {
  @PrimaryGeneratedColumn()
  id!: number;

  @Index()
  @Column("int", {
    name: "role_id",
    comment: "摊主角色ID(关联market_stalls.role_id)",
  })
  roleId!: number;

  @Column("int", { name: "pos", comment: "摊位槽位 0-4" })
  pos!: number;

  @Column("int", {
    name: "thing_id",
    comment: "物品ID/装备唯一ID/宝石唯一ID等",
  })
  thingId!: number;

  @Column("tinyint", {
    name: "thing_type",
    comment: "类型: 1药 2酒 3石 4杂 5装备 6将 7其他",
    default: 1,
  })
  thingType!: number;

  @Column("varchar", {
    length: 100,
    name: "name",
    comment: "展示名称",
    default: "",
  })
  name!: string;

  @Column("int", { name: "lvl", comment: "等级/品阶", default: 0 })
  lvl!: number;

  @Column("int", { name: "weight", comment: "重量(用于展示)", default: 0 })
  weight!: number;

  @Column("int", { name: "count", comment: "数量", default: 1 })
  count!: number;

  @Column("int", { name: "money", comment: "单价(银两)", default: 0 })
  money!: number;

  @Column("tinyint", {
    name: "status",
    comment: "状态: 1-在架,0-已售/撤销",
    default: 1,
  })
  status!: number;

  @Column("datetime", { name: "created_at", comment: "创建时间" })
  created_at!: Date;

  @Column("datetime", {
    name: "updated_at",
    nullable: true,
    comment: "更新时间",
  })
  updated_at!: Date | null;
}
